package com.yuanchu.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.common.utils.PageUtils;
import com.yuanchu.common.utils.Query;
import com.yuanchu.goods.dao.YoshopSpecValueDao;
import com.yuanchu.goods.entity.YoshopSpecValueEntity;
import com.yuanchu.goods.service.YoshopSpecValueService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("yoshopSpecValueService")
public class YoshopSpecValueServiceImpl extends ServiceImpl<YoshopSpecValueDao, YoshopSpecValueEntity> implements YoshopSpecValueService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<YoshopSpecValueEntity> page = this.page(
                new Query<YoshopSpecValueEntity>().getPage(params),
                new QueryWrapper<YoshopSpecValueEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public YoshopSpecValueEntity getSpecValueId(String specValue) {
        if (StringUtils.isEmpty(specValue)) {
            return null;
        }
        YoshopSpecValueEntity specValueEntity = this.getOne(new QueryWrapper<YoshopSpecValueEntity>().eq("spec_value", specValue));
        return specValueEntity;
    }

}